#include "BFSTravel.h"
void BFSTravel(TreeNode* root, vector<int>& cache)
{
    if (!root)
        return;
    else
    {
        queue<TreeNode*> q;
        q.push(root);
        TreeNode* tmp;
        while (q.size())
        {
            tmp = q.front();
            q.pop();
            cache.push_back(tmp->val);
            if (tmp->left)
                q.push(tmp->left);
            if (tmp->right)
                q.push(tmp->right);
        }
    }
}
vector<int> BFSTravel(TreeNode* root)
{
    vector<int> res;
    BFSTravel(root, res);
    return res;
}
